//
//  ThreeImageTableViewCell.m
//  MusicNews
//
//  Created by lanou3g on 15/10/13.
//  Copyright © 2015年 LC.J. All rights reserved.
//

#import "ThreeImageTableViewCell.h"
#import "NewsModel.h"
#import "UIImageView+WebCache.h"

@implementation ThreeImageTableViewCell




- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        if ([UIScreen mainScreen].bounds.size.width == 320) {
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.bounds.size.width - 40, 30)];
            _replyCount = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 55, 5, 70, 20)];
            _iamge1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 35, (self.bounds.size.width - 40) / 3, 90)];
            _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake((self.bounds.size.width - 40) / 3 + 21, 35, (self.bounds.size.width - 40) / 3 , 90)];
            _iamge3 = [[UIImageView alloc] initWithFrame:CGRectMake((self.bounds.size.width - 40) / 3 * 2 + 32, 35, (self.bounds.size.width - 40) / 3 , 90)];
            
        }else if([UIScreen mainScreen].bounds.size.width == 375){
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.bounds.size.width - 40, 30)];
            _replyCount = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 20, 5, 70, 20)];
            _iamge1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 35, (self.bounds.size.width - 40) / 3 + 20, 90)];
            _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake((self.bounds.size.width - 40) / 3 + 38, 35, (self.bounds.size.width - 40) / 3 + 20, 90)];
            _iamge3 = [[UIImageView alloc] initWithFrame:CGRectMake((self.bounds.size.width - 40) / 3 * 2 + 65, 35, (self.bounds.size.width - 40) / 3 + 20, 90)];
            
        }else{
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.bounds.size.width - 40, 30)];
            _replyCount = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 20, 5, 70, 20)];
            _iamge1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 35, (self.bounds.size.width - 40) / 3 + 20, 90)];
            _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake((self.bounds.size.width - 40) / 3 + 58, 35, (self.bounds.size.width - 40) / 3 + 20, 90)];
            _iamge3 = [[UIImageView alloc] initWithFrame:CGRectMake((self.bounds.size.width - 40) / 3 * 2 + 105, 35, (self.bounds.size.width - 40) / 3 + 20, 90)];
        }
        _replyCount.font = [UIFont systemFontOfSize:13];
        _replyCount.alpha = 0.7;
        [self addSubview:_titleLabel];
        [self addSubview:_replyCount];
        [self addSubview:_iamge1];
        [self addSubview:_iamge2];
        [self addSubview:_iamge3];
    }
    return self;
    
}


- (void)setNewsModel:(NewsModel *)newsModel
{
    _newsModel = newsModel;
    
    [_iamge1 sd_setImageWithURL:[NSURL URLWithString:self.newsModel.imgsrc] placeholderImage:[UIImage imageNamed:@"Kplace"]];
    [_iamge2 sd_setImageWithURL:[NSURL URLWithString:[self.newsModel.imgextra[0] objectForKey:@"imgsrc"]] placeholderImage:[UIImage imageNamed:@"Kplace"]];
    [_iamge3 sd_setImageWithURL:[NSURL URLWithString:[self.newsModel.imgextra[1] objectForKey:@"imgsrc"]] placeholderImage:[UIImage imageNamed:@"Kplace"]];
    _titleLabel.text = self.newsModel.title;
    _replyCount.text = [NSString stringWithFormat:@"%@跟帖", self.newsModel.replyCount];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
